home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2005 October / PCWOCT05.iso / Software / FromTheMag / Ant Movie Catalog 3.5.0.2 / amc_install.exe / {app} / Scripts / Kinoshara (RU).ifs < prev    next >
Text File  |  2005-04-09  |  7KB  |  252 lines

  1. (***************************************************
  2.  
  3. Ant Movie Catalog importation script
  4. www.antp.be/software/moviecatalog/
  5.  
  6. [Infos]
  7. Authors=LA (Andrey Lukyanov)       (<link>l_a@hotmail.ru</link>)
  8. Title=Kinoshara
  9. Description=Imports russian movies info with picture from Kinoshara.com
  10. Site=http://kinoshara.com
  11. Language=RU
  12. Version=1.01 (27.03.2005)
  13. Requires=3.5.0
  14. Comments=
  15. License=This program is free software; you can redistribute it and/or modify it under the  terms of the GNU General Public License as published by the Free Software Foundation;  either version 2 of the License, or (at your option) any later version. |
  16. GetInfo=1
  17.  
  18. [Options]
  19. ***************************************************)
  20. program KinoShara;
  21. const
  22.   BaseAddress = 'http://kinoshara.com/';
  23. var
  24.   MovieName: string;
  25.  
  26. function ParseURL(Text:String):String;
  27. var
  28.   BeginPos : Integer;
  29.   EndPos : Integer;
  30.   Value : String;
  31. begin
  32.  
  33.   repeat
  34.     BeginPos := Pos('<b>',Text);
  35.     If BeginPos > 0 Then
  36.     Begin
  37.       EndPos := Pos('</b>',Text);
  38.       Value := copy(Text, BeginPos, EndPos - BeginPos);
  39.       Value := StringReplace(Value,'<BR>',', ');
  40.       Value := StringReplace(Value,'<br>',', ');
  41.       HTMLRemoveTags(Value);
  42.       Delete(Text,1,EndPos);
  43.       If Length(result)>0 Then
  44.         result := result + ', ' + Value
  45.       else
  46.         result := Value;
  47.     end;
  48.   until BeginPos < 1;
  49.  
  50. end;
  51.  
  52. function FindLine(Pattern: string; List: TStringList; StartAt: Integer): Integer;
  53. var
  54.   i: Integer;
  55. begin
  56.   result := -1;
  57.   if StartAt < 0 then
  58.     StartAt := 0;
  59.   for i := StartAt to List.Count-1 do
  60.     if Pos(AnsiLowerCase(Pattern), AnsiLowerCase(List.GetString(i))) <> 0 then
  61.     begin
  62.       result := i;
  63.       Break;
  64.     end;
  65. end;
  66.  
  67. procedure AnalyzePage(Address: string);
  68. var
  69.   ID, FilmName, Line: String;
  70.   Page: TStringList;
  71.   FilmPage: TStringList;
  72.   BeginPos, EndPos, LineBeginPos: Integer;
  73. begin
  74.   Page := TStringList.Create;
  75.   Page.Text := GetPage(Address);
  76.   PickTreeClear; // ╬≈Φ±≥Ωα Σσ≡σΓα ⌠Φδⁿ∞εΓ
  77.   PickTreeAdd('╧εΦ±Ω ∩ε ±δεΓ≤: ' + MovieName, '');
  78.   LineBeginPos := 0;
  79.   repeat
  80.     BeginPos := FindLine('    <tr valign=top bgcolor=#EEEEEE>', Page, LineBeginPos+1);
  81.     LineBeginPos := BeginPos;
  82.     if  BeginPos > 0 then
  83.       begin
  84.         // ┬√ΓεΣ ⌠Φδⁿ∞εΓ Γ Σσ≡σΓε
  85.         Line:= Page.GetString(BeginPos+1); // ╧εδ≤≈Φ≥ⁿ ±≥≡εΩ≤ ± αΣ≡σ±α∞Φ
  86.         repeat
  87.               BeginPos := Pos('        <td>',Line);
  88.               If BeginPos>0 Then
  89.               // ∩εΦ±Ω Γετ∞εµφ√⌡ Γα≡Φαφ≥εΓ
  90.               begin
  91.                 Delete(Line,1,BeginPos); //╙ΣαδσφΦσ φα≈αδα
  92.                 // ∩εδ≤≈ασ∞ αΣ≡σ±
  93.                 BeginPos:=Pos('<a href="',Line)+9;
  94.                 EndPos := Pos('">',Line);
  95.                 ID := copy(Line, BeginPos, EndPos - BeginPos); // ╧εδ≤≈Φ≥ⁿ αΣ≡σ± ±≥≡αφΦ÷√
  96.  
  97.                 // Γ√≥α±ΩΦΓασ∞ φατΓαφΦσ
  98.                 BeginPos := Pos('/">',Line)+3;
  99.                 EndPos := Pos('</a>',Line);
  100.                 FilmName := Copy(Line, BeginPos, EndPos - BeginPos); // ╧εδ≤≈Φ≥ⁿ φατΓαφΦσ Σδ  Γ√ßε≡α
  101.                 FilmName := StringReplace(FilmName,' ',' ');
  102.                 FilmName := StringReplace(FilmName,'<font color=red>','');
  103.                 FilmName := StringReplace(FilmName,'</font>','');
  104.                 PickTreeAdd(FilmName, ID);
  105.               end;
  106.         until BeginPos < 1;
  107.       end;
  108.   until LineBeginPos < 1;
  109.  
  110.   If  PickTreeExec(Address) Then
  111.       AnalyzeMoviePage(Address); // ╧≡εαφαδΦτΦ≡εΓα≥ⁿ ±≥≡αφΦ÷≤ ± ⌠Φδⁿ∞ε∞
  112. end;
  113.  
  114. procedure AnalyzeMoviePage(Address: String);
  115. var
  116.   Page: TStringList;
  117.   LineNr : Integer;
  118.   Line, Value, TmpStr : String;
  119.   BeginPos, EndPos : Integer;
  120.  
  121. begin
  122.   Page := TStringList.Create;
  123.   Page.Text := GetPage(Address);
  124.   //Page.SaveToFile('c:\inet\page.txt'); //!╬≥δαΣΩα
  125.  
  126.   // URL
  127.   SetField(fieldURL,Address);
  128.  
  129.   //Rating
  130.  
  131.   // Translated Title
  132.   TmpStr := '<td><b>═ατΓαφΦσ:</b> ';
  133.   LineNr := FindLine(TmpStr, Page, 0);
  134.   if LineNr > -1 then
  135.   begin
  136.     Line := Page.GetString(LineNr);
  137.     Line := StringReplace(Line,TmpStr,'');
  138.     HTMLDecode(Line);
  139.     HTMLRemoveTags(Line);
  140.     Value := Trim(Line);
  141.     SetField(fieldTranslatedTitle,Value);
  142.   end;
  143.  
  144.   // Original Title
  145.   TmpStr := '<td><b>═ατΓαφΦσ Γ ε≡ΦπΦφαδσ:</b> ';
  146.   LineNr := FindLine(TmpStr, Page, 0);
  147.   if LineNr > -1 then
  148.   begin
  149.     Line := Page.GetString(LineNr);
  150.     Line := StringReplace(Line,TmpStr,'');
  151.     HTMLDecode(Line);
  152.     HTMLRemoveTags(Line);
  153.     Value := Trim(Line);
  154.     if Value='' then Value := GetField(fieldTranslatedTitle);
  155.     SetField(fieldOriginalTitle, Value);
  156.   end;
  157.  
  158.   // Year
  159.   TmpStr := '<td><b>├εΣ Γ√∩≤±Ωα:</b> ';
  160.   LineNr := FindLine(TmpStr, Page, 0);
  161.   if LineNr > -1 then
  162.   begin
  163.     Line := Page.GetString(LineNr);
  164.     Line := StringReplace(Line,TmpStr,'');
  165.     HTMLDecode(Line);
  166.     HTMLRemoveTags(Line);
  167.     Value := Trim(Line);
  168.     SetField(fieldYear, Value);
  169.   end;
  170.  
  171.   //Category
  172.   TmpStr :='<td><b>╞αφ≡:</b> ';
  173.   LineNr := FindLine(TmpStr, Page, 0);
  174.   if LineNr > -1 then
  175.   begin
  176.     Line := Page.GetString(LineNr);
  177.     Line := StringReplace(Line,TmpStr,'');
  178.     HTMLDecode(Line);
  179.     HTMLRemoveTags(Line);
  180.     Value := Trim(Line);
  181.     Value := StringReplace(Value,'/',', ');
  182.     SetField(fieldCategory, Value);
  183.   end;
  184.  
  185.   //Country
  186.  
  187.   // Director
  188.   TmpStr := '<td><b>╨σµΦ±±σ≡:</b> ';
  189.   LineNr := FindLine(TmpStr, Page, 0);
  190.   if LineNr > -1 then
  191.   begin
  192.     Line := Page.GetString(LineNr);
  193.     Line := StringReplace(Line,TmpStr,'');
  194.     HTMLDecode(Line);
  195.     HTMLRemoveTags(Line);
  196.     Value := Trim(Line);
  197.     SetField(fieldDirector, Value);
  198.   end;
  199.  
  200.   // Producer
  201.  
  202.   // Actors
  203.   TmpStr := '<td><b>┬ ≡εδ ⌡:</b> ';
  204.   LineNr := FindLine(TmpStr, Page, 0);
  205.   if LineNr > -1 then
  206.   begin
  207.     Line := Page.GetString(LineNr);
  208.     Line := StringReplace(Line,TmpStr,'');
  209.     HTMLDecode(Line);
  210.     HTMLRemoveTags(Line);
  211.     Value := Trim(Line);
  212.     SetField(fieldActors, Value);
  213.   end;
  214.  
  215.   // Description
  216.   TmpStr := '<td><b>╬ ⌠Φδⁿ∞σ:</b> ';
  217.   LineNr := FindLine(TmpStr, Page, 0); //═α≈αδε ±≥≡εΩΦ ε∩Φ±αφΦ 
  218.   if LineNr > -1 then
  219.   begin
  220.     Line := Page.GetString(LineNr);
  221.     Line := StringReplace(Line,TmpStr,'');
  222.     Line := StringReplace(Line, '<br>', #13#10);
  223.     Line := StringReplace(Line, '<BR>', #13#10);
  224.     HTMLDecode(Line);
  225.     HTMLRemoveTags(Line);
  226.     Value := Trim(Line);
  227.     SetField(fieldDescription,Value);
  228.   end;
  229.  
  230.   // Picture
  231.   TmpStr := '    <td valign=top><a href="http://kinoshara.com/uploads/';
  232.   LineNr := FindLine(TmpStr, Page, 0); // ═α≈αδε ±≥≡εΩΦ ± ≡Φ±≤φΩε∞
  233.   if LineNr > -1 then
  234.   begin
  235.     Line := Page.GetString(LineNr);
  236.     BeginPos := 29;
  237.     EndPos := pos('" ', Line);
  238.     Value := copy(Line, BeginPos, EndPos - BeginPos);
  239.     Address := Value;
  240.     GetPicture(Address);
  241.   end;
  242. // DisplayResults;
  243. end;
  244.  
  245. begin
  246.     MovieName := GetField(fieldOriginalTitle);
  247.     if MovieName = '' then
  248.       MovieName := GetField(fieldTranslatedTitle);
  249.     if Input('Import from Kinoshara', 'Enter the title of the movie:', MovieName) then
  250.       AnalyzePage('http://kinoshara.com/search.php?search='+UrlEncode(MovieName));
  251. end.
  252.